using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace Sublimation
{
    public class Player : GameComponent
    {
        protected WorldProperties worldProperties;
        protected PlayerRace race;
        public PlayerRace Race
        {
            get { return this.race; }
        }

        protected PlayerRallyPoint rallyPoint;
        public PlayerRallyPoint RallyPoint
        {
            get { return rallyPoint; }
        }

        // could replace the lists with fixed size arrays for a speed improvement at the cost of memory
        // J: this wouldnt cost memory, it would gain memory. Cost is convenience
        protected List<FriendlyUnit> units;
        public List<FriendlyUnit> Units
        {
            get { return units; }
        }
        protected List<Tower> towers;
        public List<Tower> Towers
        {
            get { return towers; }
        }

        public Player(WorldProperties worldProperties)
            : base(worldProperties.Game)
        {
            worldProperties.Game.Components.Add(this) ;
            UpdateOrder = 80; 
            this.worldProperties = worldProperties;

            race = new PlayerRace();
            //rallyPoint = new PlayerRallyPoint(game);
            units = new List<FriendlyUnit>();
            towers = new List<Tower>();

            addTower(300, 300);
            addTower(650, 400);
            addTower(350, 700);
        }

        public override void Initialize()
        {
            base.Initialize();
        }

        public void addTower(float x, float y)
        {
            towers.Add(worldProperties.Factory.GetTower(worldProperties, this, new Vector2(x, y)));
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }
    }
}